#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#define INIFITE 0x3f3f3f3f3f3f3f3f
#define MAX 505
#include <cstring>
typedef long long ll;
using namespace std;
ll V[MAX];
ll res[MAX];
ll mark[MAX];
ll mar[MAX];
ll visited[MAX];
ll e[MAX][MAX];
int n;
int st,en;
void Dijkstra(vector<vector<int> > Edge ) {
    memset(visited,0,sizeof(visited));
    memset(mark,0,sizeof(mark));
    mark[st]=mar[st];
    for (int i=0; i<n; i++) res[i]=e[st][i];
    int pre;
    ll ma;
    while(1) {
        pre=-1;
        ma=INIFITE;
        for (int i=0; i<n; i++) {
            if (res[i]<ma && !visited[i]) {
                ma=res[i];
                pre=i;
            }
        }
        if (pre<0) break;
        visited[pre]=true;
        for (int i=0; i<Edge[pre].size(); i++) {
            if (e[st][pre] + e[pre][Edge[pre][i]] < e[st][Edge[pre][i]] ) {
                mark[Edge[pre][i]]=mark[pre] + mar[Edge[pre][i]];
                e[st][Edge[pre][i]]=e[st][pre] + e[pre][Edge[pre][i]];
                res[Edge[pre][i]]=e[st][Edge[pre][i]];
            }
            else if (e[st][pre] + e[pre][Edge[pre][i]] == e[st][Edge[pre][i]] ) {
                if (mark[pre] + mar[Edge[pre][i]] > mark[Edge[pre][i]])
                     mark[Edge[pre][i]]=mark[pre] + mar[Edge[pre][i]];
            }
        }
    }
}
int main() {
    int a,b;
    ll c;
    int m;
    scanf("%d%d%d%d", &n, &m, &st, &en);
    for (int i=0; i<n; i++) scanf("%lld", &mar[i]);
    vector< vector<int> > Edge(n);
    memset(e,0x3f,sizeof(e));
    for (int i=0; i<m; i++) {
        scanf("%d%d%lld",&a,&b,&c);
        Edge[a].push_back(b);
        e[a][b]=c;
        Edge[b].push_back(a);
        e[b][a]=c;
    }
    for (int i=0; i<n; i++) e[i][i]=0;
    Dijkstra(Edge);
    //for (int i=0; i<n; i++) cout<<res[i]<<" "<<mark[i]<<" | ";
    //cout<<endl;
    printf("%lld %lld\n", res[en], mark[en]);
    return 0;
}
/*
6 7 0 5
1 2 3 4 5 6
0 1 1
0 5 9
1 4 1
4 5 2
0 4 2
0 2 8
0 3 7

6 7 2 5
1 2 3 4 5 6
0 1 1
0 5 9
1 4 1
4 5 2
0 4 2
0 2 8
0 3 7

*/
